﻿<phone:PhoneApplicationPage 
	x:Class="Coding4Fun.WheresMyCar.MainPage"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	
    xmlns:my="clr-namespace:Coding4Fun.WheresMyCar" 
    xmlns:ControlTiltEffect="clr-namespace:ControlTiltEffect" xmlns:Converters="clr-namespace:Coding4Fun.Phone.Controls.Converters;assembly=Coding4Fun.Phone.Controls" ControlTiltEffect:TiltEffect.IsTiltEnabled="True"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	SupportedOrientations="Portrait" Orientation="Portrait"
    x:Name="PageRoot"
	mc:Ignorable="d" 
    d:DesignWidth="480" d:DesignHeight="728">

    <phone:PhoneApplicationPage.Resources>
        <my:DistanceConverter x:Key="DistanceConverter"/>
        <my:FormatConverter x:Key="FormatConverter"/>
        <my:ValueToVisibilityConverter x:Key="ValueToVisibilityConv" />
        <Converters:ThemedImageConverter x:Key="ThemedImageConverter" />
        <my:ImageConverter x:Key="ImageConverter" />

        <Style x:Key="mapStyle" TargetType="Button">
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}" />
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
						<Grid>
							<Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="1">
								<Grid>
									<Rectangle Fill="{StaticResource PhoneAccentBrush}" Opacity="0" />
                                    <Image DataContext="/images/{0}/bigCar.png"
                                        Source="{Binding Converter={StaticResource ThemedImageConverter}}" Stretch="None"/>
                                    <Image Source="{Binding MapImage, Converter={StaticResource ImageConverter}, ConverterParameter=no-cache}" Stretch="None" />
                                    <ContentPresenter />
                                    <Grid Width="75" VerticalAlignment="Top" HorizontalAlignment="Left">
										<Rectangle Fill="{StaticResource PhoneAccentBrush}" Opacity=".8" />
										<TextBlock Text="Map" TextAlignment="Center" />
									</Grid>
                                </Grid>
							</Border>
						</Grid>
						
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="photoStyle" TargetType="Button">
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}" />
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
						<Grid>
							<Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="1">
								<Grid>
									<Rectangle Fill="{StaticResource PhoneAccentBrush}" Opacity="0" />
                                    <Image DataContext="/images/{0}/bigCamera.png"
                                        Source="{Binding Converter={StaticResource ThemedImageConverter}}" Stretch="None" />
                                    <ContentPresenter />
                                    <Grid Width="75" VerticalAlignment="Top" HorizontalAlignment="Left">
										<Rectangle Fill="{StaticResource PhoneAccentBrush}" Opacity=".8" />
										<TextBlock Text="Photo" TextAlignment="Center" />	
									</Grid>
								</Grid>
							</Border>
						</Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot contains the root grid where all other page content is placed-->

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,0">
            <TextBlock x:Name="ApplicationTitle" Text="WHERE'S MY CAR" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="Overview" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

		<Grid Grid.Row="1" Margin="12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

			<Button Margin="0,10" Grid.Row="0" Style="{StaticResource mapStyle}" Click="MapClick">
				<Grid x:Name="MapGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Grid VerticalAlignment="Bottom" HorizontalAlignment="Right">
						<Rectangle Fill="{StaticResource PhoneAccentBrush}" Opacity=".8" />
                        <StackPanel Orientation="Horizontal" Margin="10,3" Visibility="{Binding Settings.ParkingSpot, Converter={StaticResource ValueToVisibilityConv}}" >
                            <TextBlock Text="{Binding Settings.DistanceToCar, Converter={StaticResource DistanceConverter}}" Margin="10,0,0,0" />
							<TextBlock Text=" from car" />
						</StackPanel>
					</Grid>
				</Grid>
			</Button>

			<Button Margin="0,10" Grid.Row="1" Style="{StaticResource photoStyle}" Click="PhotoClick" >
                <Image Source="{Binding Settings.Photo, Converter={StaticResource ImageConverter}, ConverterParameter=images/camera_icon.jpg}"  Stretch="Uniform" />
            </Button>
        </Grid>
	</Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.MenuItems>
				<shell:ApplicationBarMenuItem 
					x:Name="menuSettings" 
					Click="menuSettingsClick" 
					Text="settings..." />
				
				<shell:ApplicationBarMenuItem 
					x:Name="menuAbout" 
					Click="menuAboutClick" 
					Text="about" />
				
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
